<?php
namespace app\model\v1\recovery;

use think\Model;

class RecoveryIndustry extends Model
{
    protected $updateTime = false;
    protected $createTime = false;


    /**
     * 新增店铺转让 - 获取行业数据列表
     * @param $id
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getIndustryData($id = 0)
    {
        $result = [];
        //根据id进行获取层级数据
        $item = self::where('pid',$id)->select()->toArray();
        if ($item){
            foreach($item as $k=> $v) {
                $item[$k]['children'] = [];
                $data = self::getIndustryData($v['id']);  //根据id进行递归获取数据
                if ($data){
                    foreach($data as $kk=> $vs) {
                        $item[$k]['children'][$kk] = $vs;
                    }
                }
                $result[$k] =$item[$k];
            }
        }
        return $result;
    }


}